package pers.ree.demo.concurrent;

import java.util.concurrent.TimeUnit;

public class SynchronizedDemo {

    private static boolean isOver = false;


    public static void main(String[] args) {
        test1();
    }

    public static void test1() {
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                while (!isOver) {
                    System.out.println("thread --- true");
                }
            }
        });
        t1.start();
        try {
            TimeUnit.MILLISECONDS.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
//        synchronized (SynchronizedDemo.class) {
//            isOver = true;
//        }
        isOver = true;
        System.out.println("main --- true");
    }
}
